package com.wtwd.campus.service;

import com.wtwd.campus.entity.DeviceInfo;
import com.wtwd.campus.entity.MqLocationData;
import com.wtwd.campus.entity.MqPhoneDatas;
import com.wtwd.campus.hxy.service.CommandRecordService;

/**
 * @author mjy
 * @date 2022/11/09
 * @description
 */
public interface CustomerDealCmdService {

    /**
     * 所有号码类型
     */
    String ALL_PHONE_TYPE = "4";

    /**
     * 获取客户号码类指令发送数据
     *
     * @param imei
     * @param deviceType
     * @param customerId
     * @param type
     * @param commandNumber
     * @return
     */
    MqPhoneDatas getPhoneData(String imei, Integer deviceType, Integer customerId, String type, String commandNumber);

    /**
     * 处理客户号码类数据
     *
     * @param imei
     * @param deviceType
     * @param customerId
     * @param type
     * @param phoneDatas
     * @return
     */
    Boolean dealCustomerGetPhoneData(String imei, Integer deviceType, Integer customerId, String type, MqPhoneDatas phoneDatas);

    /**
     * 处理多边形围栏
     *
     * @param mqLocationData
     * @param deviceInfo
     * @param address
     * @param locationTime
     * @return
     */
    Boolean dealCustomerPolygonFence(MqLocationData mqLocationData, DeviceInfo deviceInfo, String address, long locationTime);

    CommandRecordService getCommandRecordService();

    RedisService getRedis();

    /**
     * 根据指令前缀，删除某个类型的指令
     * 清除缓存
     *
     * @param imei
     * @param cmdPrefix
     * @return
     */
    default boolean deleteCacheCmd(String imei, String cmdPrefix) {
        RedisService redisService = getRedis();
        CommandRecordService commandRecordService = getCommandRecordService();
        redisService.deleteHashByPrefix(imei, cmdPrefix);
        return commandRecordService.deleteCacheCmd(imei, cmdPrefix) > 0 ? true : false;
    }



}
